﻿#include "systemform.h"
#include "ui_systemform.h"
#include <QGraphicsDropShadowEffect>



SystemForm::SystemForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::SystemForm)
{
    ui->setupUi(this);


    m_pMotor = new MotorForm();
    m_pMotor->hide();
    m_pSetCamera = new CameraSetForm();
    m_pSetCamera->hide();
    m_pGradeConfig = new GradeConfigDialog(m_dRuleConfig);
    m_pGradeConfig->hide();


    ui->gridLayout->addWidget(m_pMotor,1,0);
    ui->gridLayout->addWidget(m_pSetCamera,1,0);
    ui->gridLayout->addWidget(m_pGradeConfig,1,0);
    ui->gridLayout->setSpacing(0);

    qDlg = m_pMotor;
    SwitchFrom(0);


    //内层窗口添加对应的阴影效果
    QGraphicsDropShadowEffect *shadow_effect = new QGraphicsDropShadowEffect(this);
    shadow_effect->setOffset(0, 0);
    shadow_effect->setColor(QColor(150,150,150));
    shadow_effect->setBlurRadius(6);
    ui->widget_title->setGraphicsEffect(shadow_effect);
}

SystemForm::~SystemForm()
{
    delete ui;
}

void SystemForm::SwitchFrom(int index)
{

    qDlg->hide();
    switch (index) {
    case 0:
        qDlg = m_pMotor;
        break;
    case 1:
        qDlg = m_pSetCamera;
        break;
    case 2:
        qDlg = m_pGradeConfig;
        break;
    case 3:
        // qDlg = compote;
        break;
    case 4:
        // qDlg = peel;
        break;
    case 5:
        // qDlg = grading;
        break;
    case 6:
        // qDlg = genera;
        break;
    }
    qDlg->show();
}


void SystemForm::on_Bt_machine_clicked()
{
    SwitchFrom(0);
}


void SystemForm::on_Bt_camera_clicked()
{
    SwitchFrom(1);
}


void SystemForm::on_Bt_Grade_clicked()
{
    SwitchFrom(2);
}


